<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsppages/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 船舶日志管理</title>
	<base href="<%=basePath%>" />	
 	<meta http-equiv="pragma" content="no-cache" />
 	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<link type="image/x-icon" rel="shortcut icon" href="<%=basePath%>images/favicon.ico" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/userlist.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/pagebar_cn.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/shipService.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/DatePicker/WdatePicker.js" defer="defer"></script>
</head>

<body oncontextmenu='return false'>

	<!--top begin-->
	<%@include file="/WEB-INF/jsppages/admin/head.jsp"%>
	<!--top end-->

<div class="wrap100 content">

    <!--left begin-->
	<%@include file="/WEB-INF/jsppages/admin/left.jsp"%>
    <!--left end-->    
    
    <!--right begin-->
	<div class="right">
            <div class="search">
            	<form action="<%=basePath%>trade/shipLogList" method="GET">
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                    <td width="5%"><img src="images/marking1.gif" width="41" height="44" alt="marking" /></td>
                    <td width="8%">快速查询</td>
                    <td width="25%">时间范围：<input type="text" name="startDate" id="startDate1" value="<fmt:formatDate value="${shipInfoSearchCond.startDate}" pattern="yyyy-MM-dd"/>"  class="zi" style="width:75px;" onfocus="var end=document.getElementById('startDate2');WdatePicker({onpicked:function(){end.focus();},maxDate:end.value})"  autocomplete="off"/>
  					-<input type="text" name="startDate2" id="startDate2" value="<fmt:formatDate value="${shipInfoSearchCond.startDate2}" pattern="yyyy-MM-dd"/>"  class="zi" style="width:75px;" onfocus="WdatePicker({minDate:'#F{$dp.$(\'startDate1\').value}'})"/></td>
                    </td>
                    <td width="20%">请输入事项：<input type="text" name="item" value="${shipInfoSearchCond.item}" style="width:100px;" /></td></td>
                    <td width="11%"><input type="hidden" id="id" name="id" value="${shipInfo.id}" />
                    <input type="submit" style="background:url(images/searchBtn.gif);width:116px;height:30px;border:0;margin:0;" value="" />
                    </td>
                   <td width="30%">
                    <jsp:useBean id="nowDate" class="java.util.Date"></jsp:useBean>
   					 现在是：${formatDate}<fmt:formatDate value="${nowDate}" type="both" dateStyle="full"/>
   					</td>
                    <td width="1%">&nbsp;</td>
                  </tr>
                </table>    
                </form>
        	</div>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="60"><h1>船舶作业日志</h1></td>
              </tr>
            </table>
            
            <div class="rightContentTop">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="4%" align="center" bgcolor="#e3ecf1">船名</td>
                  <td width="13%">${shipInfo.shipName}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">国籍</td>
                  <td width="6%">${shipInfo.nationality}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">总吨</td>
                  <td width="6%">${shipInfo.total}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">净吨</td>
                  <td width="6%">${shipInfo.netton}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">IMO</td>
                  <td width="6%">${shipInfo.imo}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">呼号</td>
                  <td width="6%">${shipInfo.no}</td>
                  <td width="4%" align="center" bgcolor="#e3ecf1">代理</td>
                  <td width="6%">${shipInfo.agent}</td>
                </tr>
              </table>
              <div class="subMenu">
               	  <ul>
                    	<li><a href="<%=basePath%>trade/shipLogList?id=${shipInfo.id}" class="current">船舶作业日志</a></li>
                        <li><a href="<%=basePath%>trade/shipShopMaterialList?id=${shipInfo.id}">船方自购物料</a></li>
                        <li><a href="<%=basePath%>trade/shipMainlandMaterialList?id=${shipInfo.id}">国内采购物料上船</a></li>
                        <li><a href="<%=basePath%>trade/shipFinalMaterialList?id=${shipInfo.id}">下船物料</a></li>
                        <li><a href="<%=basePath%>trade/shipDirectoryList?id=${shipInfo.id}">单证目录</a></li>
                  </ul>
              </div>            
   			</div>
     
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                 <td align="right"><span style="float:left;color:#666;">共找到<font color="red"> ${searchStat.totalCount} </font>条记录</span>
                 <c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
                 	<a href="javascript:;" onclick="addShipLog()" style="font-weight:bold"><img src="images/add.gif" width="90" height="31" alt="添加" /></a>
                 	<!-- <a href="#"><img src="images/del.gif" width="90" height="31" alt="删除" /></a> -->
                 </c:if>
                 </td>                 
              </tr>
    	</table>
        <div class="rightContent1">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr class="td">
                <th width="5%" align="center" bgcolor="#f9f9f9"><input type="checkbox" name="checkbox4" id="checkbox4" /></th>
                <th width="5%" align="center" bgcolor="#f9f9f9">序号</th>
                <th width="10%" align="center" bgcolor="#f9f9f9">开始日期</th>
                <th width="10%" align="center" bgcolor="#f9f9f9">计划结束日期</th>
                <th width="20%" align="center" bgcolor="#f9f9f9">事项</th>
                <th width="30%" align="center" bgcolor="#f9f9f9">船方自购物料</th>
                <th width="10%" align="center" bgcolor="#f9f9f9">录入员</th>
                <th width="10%" align="center" bgcolor="#f9f9f9">操作</th>
              </tr>
              <c:forEach var="shipLog" items="${shipLogList}">
              
              <tr>
                <td align="center"><input type="checkbox" name="checkbox" id="checkbox" /></td>
                <td align="center">${shipLog.id}</td>
                <td align="center"><fmt:formatDate value="${shipLog.startDate}" pattern="yyyy-MM-dd"/></td>
                <td align="center"><fmt:formatDate value="${shipLog.endDate}" pattern="yyyy-MM-dd"/></td>
                <td>${shipLog.item}</td>
                <td align="left">${shipLog.details}</td>
                <td align="left">${shipLog.user.name} <fmt:formatDate value="${shipLog.createDate}" pattern="yyyy-MM-dd"/></td>
                <td align="left">
                	<c:if test="${sessionScope.memberSessionInfo.userType.value<2}">
                	<a href="javascript:;" onclick="delShipLog('${shipLog.id}')"><img src="images/del1.jpg" alt="删除" /></a>
                	<a href="javascript:;" onclick="editShipLog('${shipLog.id}')"><img src="images/modify.jpg" alt="修改" /></a>
                	</c:if>               	
                </td>
              </tr>
             
              </c:forEach>
			  <c:if test="${empty shipLogList}"><tr><td colspan="16" style="text-align:center">没有相关记录！</td></tr></c:if> 
              </table>
         </div>
       <script type="text/javascript">
		var pageControl = new wpagebar('pageControl');
		pageControl.argName = "pageIndex";
		pageControl.pageCount =${searchStat.pageCount};
		pageControl.load();		
  	   </script>     
  	   <div id="win_temp" style="display:none">
	<div id="winCon_1">
	<table class="tabView" style="margin-top:5px">
		<tr><th width="100">开始日期：</th><td>
		<input type="text" name="startDate0" id="startDate0" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
		<input type="text" name="shipLogId0" id="shipLogId0" style="display:none"/></td></tr>
		<tr><th>计划结束日期：</th><td><input type="text" name="endDate0" id="endDate0" value="" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td></tr>
		<tr><th>事项：</th><td><textarea id="item0" name="item0" rows="4" cols="40"></textarea></tr>
		<tr><th>船方自购物料：</th><td><textarea id="details0" name="details0" rows="4" cols="40"></textarea></td></tr>
		<tr><th>状态：</th><td><input type="radio" name="status0" checked="checked"/>启用 <input type="radio" name="status0"/>禁用</td></tr>
		<tr><td colspan="2" style="text-align:center;height:">
		<input type="hidden" id="userId0" name="userId0" value="${sessionScope.memberSessionInfo.userId}" />
		<input type="hidden" id="shipInfoId0" name="shipInfoId0" value="${shipInfo.id}" />
		<input type="button" value=" 提 交 " class="btn1" onclick="submitShipLog()"/></td></tr>
	</table>
	</div>
	
	</div>
    <script src="<%=basePath%>js/win.js" type="text/javascript"></script>
</div>
<script  type="text/javascript">
function addShipLog(){
	WIN.show('添加船舶作业日志信息',$('winCon_1'),{height:350});
}
function editShipLog(id){
	WIN.show('修改船舶作业日志信息',$('winCon_1'),{height:350});
	shipService.getShipLogById(id,function(data){
		$('shipLogId0').value=data.id;
		$('item0').value=data.item;
		$('details0').value=data.details;
		$('startDate0').value=formatDate(data.startDate);
		$('endDate0').value=formatDate(data.endDate);
		if(data.status){$N('status0')[0].checked=true;}else{$N('status0')[1].checked=true;}		
	})
}
function delShipLog(id){
	if(confirm("删除船舶作业日志，确定删除 ？")){
		WIN.showpg();
		shipService.delShipLogById(id,{
			callback:function(f){WIN.closepg();alert("删除成功");reload();},
			exceptionHandler:function(message){WIN.closepg();alert("删除失败，请重试");},
			errorHander:function(err){}
		})
	}
}
/**/
function submitShipLog(){
	var user = {id:$('userId0').value};
	var shipInfo = {id:$('shipInfoId0').value};
	if(user ==''){alert('无法获取登录信息，请重新登录!');return;}
	if(shipInfo ==''){alert('无法获取船舶信息，请重新选择船舶信息!');return;}
	var shipLog={
			id:			$('shipLogId0').value,			
			startDate:	$('startDate0').value.trim()?new Date($('startDate0').value.trim().replace(/-/g,"/")):'',
			endDate:	$('endDate0').value.trim()?new Date($('endDate0').value.trim().replace(/-/g,"/")):'',
			item:	    $('item0').value,
			details:	$('details0').value,
			status:		$N('status0')[0].checked,
			user:       user,
			shipInfo:   shipInfo
	}	
	if(''==shipLog.startDate){alert('起始时间不能为空');return;}
	if(''==shipLog.endDate){alert('计划结束日期不能为空');return;}
	if(''==shipLog.item){alert('事项不能为空');return;}
	if(''==shipLog.details){alert('船方自购物料不能为空');return;}
	submit(shipLog);	
}
function submit(log){
	WIN.close();
	WIN.showpg();
	shipService.editShipLog(log,{
		callback:function(f){WIN.closepg();alert("操作成功");reload();},
		exceptionHandler:function(message){WIN.closepg();alert(message);alert("操作失败，请重试");},
		errorHander:function(err){}
	})
}

</script>
</body>
</html>
